package zzcltw.com.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import zzcltw.com.mapper.TitleImgMapper;
import zzcltw.com.object.TitleImg;
import zzcltw.com.service.ITitleImgService;
import zzcltw.com.service.common.impl.BaseServiceImpl;
@Service("titleImgService")
public class TitleImgServiceImpl extends BaseServiceImpl implements ITitleImgService{
	@Autowired
    private TitleImgMapper titleImgMapper;
	/**
	 * 
	 * @Title  查询轮播图列表
	 * @Description:  queryTitleImgList
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> queryTitleImgList(Map<String,String> map){
		List<Map<String,String>> list = titleImgMapper.queryTitleImgList(map);
		int count = titleImgMapper.queryTitleImgListCount(map);
		Map<String,String> bean = new HashMap<>();
		bean.put("total", Integer.toString(count));
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  首页轮播图列表
	 * @Description:  queryTitleImgPageList
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> queryTitleImgPageList(Map<String,String> map){
		List<Map<String,String>> list = titleImgMapper.queryTitleImgList(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", list);
		map1.put("bean", "");
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  查询轮播图详情
	 * @Description:  queryTitleImgDtlById
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> queryTitleImgDtlById(Map<String,String> map){
		map.put("validStsCd", "1");
		Map<String,String> bean = titleImgMapper.queryTitleImgDtlById(map);
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", "");
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  保存轮播图
	 * @Description:  saveTitleImgInfo
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws Exception 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> saveTitleImgInfo(TitleImg titleImg) throws Exception{
		String titleId = getSequence("t_pt_title_img");		
		titleImg.setTitleId(titleId);
		titleImg.setValidStsCd("1");
		int flag = titleImgMapper.saveTitleImgInfo(titleImg);		
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", "");
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  编辑轮播图
	 * @Description:  updateTitleImgInfo
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> updateTitleImgInfo(TitleImg titleImg){
		titleImg.setValidStsCd("1");
    	int flag = titleImgMapper.updateTitleImgInfo(titleImg);    	
    	Map<String,Object> bean = new HashMap<>();
    	if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
		Map<String,Object> map1 = new HashMap<>();
		map1.put("beans", "");
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
	/**
	 * 
	 * @Title  删除轮播图
	 * @Description:  delTitleImgInfo
	 * @param: @param map
	 * @param: @return
	 * @return 
	 * @throws
	 * @author zzx
	 * @Date 2018年10月20日
	 */
	public Map<String,Object> delTitleImgInfo(TitleImg titleImg){
		int flag = titleImgMapper.delTitleImgInfo(titleImg);
		Map<String,Object> map1 = new HashMap<>();
		Map<String,Object> bean = new HashMap<>();
		if(flag != 1){
    		bean.put("rtnCd", "9999");
    	}else {
    		bean.put("rtnCd", "00");
    	}
		map1.put("beans", "");
		map1.put("bean", bean);
		map1.put("busiCode", "");
    	map1.put("returnCode", "0");
    	map1.put("returnMessage", "");
    	map1.put("object", "");
    	map1.put("busiCode", ""); 
		return map1;
	}
}
